package com.ylxn.creator;

public class Singleton03 {
    //私有构造方法
    private Singleton03(){}
    //私有成员变量,volatile防止指令重排
    private static volatile Singleton03 singleton03;

    public static Singleton03 getInstance(){
        if (singleton03 ==null){
            synchronized (Singleton03.class){
                if (singleton03 ==null){
                    singleton03 = new Singleton03();
                }
            }
        }
        return singleton03;
    }
}
